<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">

    <script type="text/javascript"
            src="./js/jquery-3.1.1.min.js"></script>
    <title>地图展示</title>
</head>
<body>
<div id="allmap"></div>
<form id= "uploadForm">
    <p >指定文件名： <input type="text" name="filename" value= ""/></p >
    <p >上传文件： <input type="file" name="file" id="file_upload"/></p>
    <input type="button" value="上传" onclick="doUpload()" />
</form>
</body>
</html>


<script type="text/javascript">


    var par =[
        {
        "id": "1",
        "name": "name1"
        },
        {
            "id": "2",
            "name": "name2"
        }
        ]
    var userOne =
        {
            "id": "one",
            "name": "name_one"
        }
    params = {
        "userInfo":JSON.stringify(userOne),
        "userList":JSON.stringify(par),
        "token":JSON.stringify("asaabasd")
    };
    jsonData ={"param":JSON.stringify(params)};//search_condition必须和对象中的字段对应
    $.ajax({
        type:"post",
        url:"http://localhost:8080/testpost",/*url写异域的请求地址*/
        data:params,
        dataType:"json",
        success:function(data){
            alert(data);
        }
    });
    function doUpload() {
        var formData = new FormData();
        formData.append("fileArray",$("#file_upload")[0].files[0]);   // 文件对象
        $.ajax({
            url: 'http://www.ccb717.com/n5xproject/uploadImg' ,
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (returndata) {
                alert(returndata);
            },
            error: function (returndata) {
                alert(returndata);
            }
        });
    }
</script>